<?php

namespace App\Http\Controllers\Api\V1\Site;

use Illuminate\Http\Request;
use Biz\Requests\Site\SiteHotelRoomTypeRequest;
use Biz\Services\Site\SiteHotelRoomTypeService;
use Biz\Resources\Site\SiteHotelRoomTypeResource;
use Lumen\Http\Resources\Json\DataResourceResponse;
use Laravel\Lumen\Routing\Controller as BaseController;
use Biz\Resources\Site\SiteHotelRoomTypeResourceCollection;

/**
 * HotelRoomTypeController.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class HotelRoomTypeController extends BaseController
{
    /**
     * @var mixed
     */
    protected $service;

    /**
     * HotelRoomTypeController constructor.
     *
     * @param SiteHotelRoomTypeService $service
     */
    public function __construct(SiteHotelRoomTypeService $service)
    {
        $this->service = $service;
    }

    /**
     * Display a listing of the resource.
     *
     * @param string $hotel_id
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request, string $hotel_id)
    {
        $results = $this->service->index($request, $hotel_id);

        return new SiteHotelRoomTypeResourceCollection($results);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param SiteHotelRoomTypeRequest $request
     * @param string                   $hotel_id
     *
     * @return \Illuminate\Http\Response
     */
    public function store(SiteHotelRoomTypeRequest $request, string $hotel_id)
    {
        $site = $this->service->store($request, $hotel_id);

        return new SiteHotelRoomTypeResource($site);
    }

    /**
     * Display the specified resource.
     *
     * @param string $hotel_id
     * @param string $room_type_id
     *
     * @return \Illuminate\Http\Response
     */
    public function show(string $hotel_id, string $room_type_id)
    {
        $site = $this->service->show($hotel_id, $room_type_id);

        return new SiteHotelRoomTypeResource($site);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param SiteHotelRoomTypeRequest $request
     * @param string                   $hotel_id
     * @param string                   $room_type_id
     *
     * @return \Illuminate\Http\Response
     */
    public function update(SiteHotelRoomTypeRequest $request, string $hotel_id, string $room_type_id)
    {
        $site = $this->service->edit($hotel_id, $room_type_id, $request->all());

        return new SiteHotelRoomTypeResource($site);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param string $hotel_id
     * @param string $room_type_id
     *
     * @return \Illuminate\Http\Response
     */
    public function destroy(string $hotel_id, string $room_type_id)
    {
        $result = $this->service->remove($hotel_id, $room_type_id);

        return new DataResourceResponse($result);
    }
}
